package org.gl.gui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;

import org.gl.logic.GLMapLogic;
import org.gl.obj.GLMap;

public class GLPanel extends JPanel {
		
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private GLMap map;
	private GLMapLogic gml;
	
	public GLPanel(GLMap map, GLMapLogic gml) {
		setPreferredSize(new Dimension(
				map.getSizeX() * GLMapView.SCALE,
				map.getSizeY() * GLMapView.SCALE));
		this.map = map;
		this.gml = gml;
	}

	@Override
	protected void paintComponent(Graphics g) {
		Graphics2D g2 = (Graphics2D)g;
		GLMapView.draw(g2, map);
	}
	
	public void update() {
		gml.update(map);
	}
}
